<template>
	<view class="">
		<view class="top">
			<view class="title">
				<view class="">
					常用工具
					<view class="text">
						为医生提供更方便的问诊基础
					</view>
				</view>
				<view class="tz" @click="goinfo('pages/my/news/news')">
					<image src="@/static/CommonTools/tz.png" mode=""></image>
				</view>
			</view>
			<view class="switchBox">
				<switch :checked="Status" @change='switch1Change' style="transform:scale(0.6)" />线上服务
			</view>
		</view>
		<view class="nav">
			<view @click="goinfo('pages/CommonTools/ConsultationRoomSetup/ConsultationRoomSetup')">
				<image src="@/static/CommonTools/1.png" mode=""></image>
				<view>
					诊室设置
				</view>
			</view>
			<view @click="goinfo('pages/CommonTools/reservation/reservation')">
				<image src="@/static/CommonTools/2.png" mode=""></image>
				<view>
					预约设置
				</view>
			</view>
			<view @click="goinfo('pages/CommonTools/consultation/consultation')">
				<image src="@/static/CommonTools/3.png" mode=""></image>
				<view>
					会诊设置
				</view>
			</view>
			<view @click="goinfo('pages/prescription/prescription')">
				<image src="@/static/CommonTools/4.png" mode=""></image>
				<view>
					常用药方
				</view>
			</view>
			<view @click="goinfo('pages/prescription/index')">
				<image src="@/static/CommonTools/5.png" mode=""></image>
				<view>
					常用处方
				</view>
			</view>
			<view @click="goinfo('pages/CommonTools/CommonReplies/CommonReplies')">
				<image src="@/static/CommonTools/6.png" mode=""></image>
				<view>
					常用回复
				</view>
			</view>
		</view>
		<UnauditedPup :data="data.auditStatus"></UnauditedPup>
	</view>
</template>

<script>
	import {
		updateDoctorInfo,
		getDoctorInfo,
		getDoctorStatic
	} from '@/api/user'
	export default {
		data() {
			return {
				baseFormData: {

				},
				Status: false,
				data: {}
			}
		},
		onShow() {
			this.getDoctorStatic()
		},
		onLoad() {
			this.getDoctorInfo()
		},
		methods: {
			getDoctorStatic() {
				getDoctorStatic().then(res => {
					this.data = res.data
				})
			},
			switch1Change: function(e) {
				if (e.detail.value) {
					this.baseFormData.onlineStatus = 1
				} else {
					this.baseFormData.onlineStatus = 0
				}
				this.updateDoctorInfo()
			},
			getDoctorInfo() {
				getDoctorInfo().then(res => {
					this.baseFormData = res.data
					if (this.baseFormData && this.baseFormData.onlineStatus == 1) {
						this.Status = true
					} else {
						this.Status = false
					}
				})
			},
			updateDoctorInfo() {
				updateDoctorInfo(this.baseFormData).then(res => {
					this.baseFormData = res.data
					this.getDoctorInfo()
				})
			},
			goinfo(e, id) {
				if (id) {
					uni.navigateTo({
						url: `/${e}?id=${id}`,
					})
				} else {
					uni.navigateTo({
						url: `/${e}`,
					})
				}
			},
		}
	}
</script>

<style lang="less" scoped>
	.nav {
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;

		&>view {
			width: 213rpx;
			height: 223rpx;
			position: relative;
			margin-bottom: 30rpx;

			image {
				position: absolute;
				top: 0;
				left: 0;
				width: 213rpx;
				height: 223rpx;
			}

			view {
				position: absolute;
				top: 146rpx;
				text-align: center;
				width: 100%;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333 // left: 50%;
					// transform: translateX(-50%);
			}
		}
	}

	.top {
		width: 750rpx;
		height: 380rpx;
		background-image: url(@/static/CommonTools/bg.png);
		background-size: 100% 100%;
		padding: 0 30rpx;
		box-sizing: border-box;

		.switchBox {
			display: flex;
			align-items: center;
			margin-top: 36rpx;
			font-weight: 500;
			font-size: 26rpx;
			color: #3B6CFE;
		}

		.title {
			display: flex;
			justify-content: space-between;
			font-weight: bold;
			font-size: 36rpx;
			color: #333333;
			padding-top: 177rpx;

			image {
				width: 60rpx;
				height: 68rpx;
			}

			.text {
				font-weight: 500;
				font-size: 26rpx;
				color: #999999;
				margin-top: 25rpx;
			}
		}
	}
</style>